#pragma once

//
// simple file io utility functions
//
// Exceptions are thrown on any unexpected failure or state mismatch.
//
// no RAII... so callers can leak handles.  Don't do that.
//
// also, no FILE_SHARE_* flags are used.  The file is opened, an operation is performed, the file is closed.
//
namespace FileIO
{
	LARGE_INTEGER GetFileSize(const std::wstring & filename);

	void SetExistingFileSparse(const std::wstring & filename);
	void CreateNewFileAsSparseWithSize(const std::wstring & filename, LARGE_INTEGER liFileSize);

	void SetExistingFileNotSparse(const std::wstring & filename);

	void MarkSparseRange(const std::wstring & filename, ULONGLONG begin, ULONGLONG end);

	HANDLE OpenFileRead(const std::wstring & filename);
	HANDLE OpenFileWrite(const std::wstring & filename);

	void CloseFile(HANDLE * phFile);
	void DeleteFile(const std::wstring & filename);
}
